Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
electron-window
Advanced tools
Convenience methods for Electron windows.
npm i --save electron-window
electron-window
converts this:
var app = require('app')
var path = require('path')
var url = require('url')
var BrowserWindow = require('browser-window')
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the javascript object is GCed.
var mainWindow = null
app.on('ready', function () {
mainWindow = new BrowserWindow({ width: 1000, height: 400, show: false })
var someArgs = { data: 'hi' }
var indexPath = path.resolve(__dirname, '..', 'weird-location', 'index.html')
var indexUrl = url.format({
protocol: 'file',
pathname: indexPath,
slashes: true,
hash: encodeURIComponent(JSON.stringify(someArgs))
})
mainWindow.on('closed', function() {
mainWindow = null
})
mainWindow.webContents.on('did-finish-load', function() {
mainWindow.show()
console.log('window is now visible!')
})
mainWindow.loadUrl(indexUrl)
})
to this:
var app = require('app')
var path = require('path')
var window = require('electron-window')
app.on('ready', function () {
var mainWindow = window.createWindow({width: 1000, height: 400})
var someArgs = { data: 'hi' }
var indexPath = path.resolve(__dirname, '..', 'weird-location', 'index.html')
mainWindow.showUrl(indexPath, someArgs, function () {
console.log('window is now visible!')
})
})
Class method that creates a new BrowserWindow with
the following default options
: {show: false}
. No need to worry about keeping a global reference
to prevent garbage collection, this is handled for you.
Instance method to parse arguments in window. You would only need to call from your renderer preload script if you pass in
preload
.
Instance method that shows the url. When the url is finished loading, the callback is returned. If the optional argsForRenderer
is set
then __args__
will be a global object for the page in the renderer process. This is a convenient way to pass
arguments from the main process to the renderer process.
Instance method to call if you ever want to remove the global reference. Should only need to be called if
destroy()
is ever called.
Most likely, you won't need to use this.
Class property to get a reference to all windows created and their ids.
main process
var window = require('electron-window')
var windowOptions = {
width: 1000,
height: 400
}
var mainWindow = window.createWindow(windowOptions)
// can access at window.__args__ from scripts
// ran from index.html
var args = {
data: 'some secret data'
}
mainWindow.showUrl('index.html', args, function() {
console.log('the window should be showing with the contents of the URL now')
})
renderer process
// only call if `preload` is set in `windowOptions`
require('electron-window').parseArgs()
console.log(window.__args__)
// => Object {data: "some secret data"}
MIT
FAQs
Convenience methods for Electron windows.
We found that electron-window demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.